<?php
	include "connection-provider.php";
?>


<?php




session_start();


			

$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="smartinterview"; // Database name
$tbl_name="logintime_details"; // Table name
$name = $_SESSION['username'];


 
$ipaddress = $_SERVER['REMOTE_ADDR'];

			$result = mysqli_query($con,"SELECT * FROM `login_details` WHERE UserName='$name'");		
			while($row = mysqli_fetch_array($result))
				{
					$studentId = $row['userID'];
				}


mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql="INSERT INTO `$tbl_name` (userID,login_time,logout_time,IPaddress,Status)
         VALUES('$name',now(),'','$ipaddress','active')";
		 $result=mysql_query($sql);
		 $status= "active";
$sql1="UPDATE login_details SET Status='$status' WHERE UserName='$name'";
$result1=mysql_query($sql1);

         // Check connection
           // if (mysqli_connect_errno())
            // {
           //echo "Failed to connect to MySQL: " . mysqli_connect_error();
            // }
			//$sql="INSERT INTO 'logintime_details' (UserID,login_time,logout_time,IPaddress,Status)
         //VALUES('$_SESSION['$username']','$_SERVER['REQUEST_TIME']','','$_SERVER['REMOTE_ADDR']','')";
		 // if (!mysqli_query($con,$sql))
          //{
          //die('Error: ' . mysqli_error($con));
          // }
		   
		   
?>

<html>
<body>
Login Successful
<a href="logout.php">Log out</a>
</body>
</html>






<div style="width:960px; margin:0 auto;">
<?php
	
			$count = 0;
	$result = mysqli_query($con,"SELECT * FROM `total_marks_table` WHERE student_id='$studentId' && submit_status='submitted'");
	
			while($row = mysqli_fetch_array($result))
				{
					$count++;
				}
	
	if($count ==2)
	{
		echo "Test Already Completed";
	}
	else
	{
?>


	<fieldset>
	<form action="start-test.php" method="POST">
	
	Select Question Type : 
<?php

		
		if(!isset($_GET['typeId']))
		{
			$typeId = 0;
		}
		else
		{
		$typeId = $_GET['typeId'];
		}
		//echo $typeId;
		
		//exit(0);
		
		$questionTable = "question_type";
		$result = mysqli_query($con,"SELECT * FROM `$questionTable`");	
			echo "<select name='questionOptionName'>";
		while($row = mysqli_fetch_array($result))
			{	
?>
		
			<option value="<?php echo $row['QTypeID']; ?>"><?php if($typeId != $row['QTypeID']){echo $row['QType'];} ?></option>			
<?php		
			}
			echo "</select> <br/>";
?>			
			
			<input type="submit" name="selectQuestionType" value="Select">
			
</form>
</fieldset>
<?php
}
?>
</div>


	